[ Home ] [ Authors ] [ Index ] [ Abbreviations ] [ Bindings ]

Dialog Procedures

Tycho provides a set of ordinary procedures, defined in the tycho namespace, that serve as simplified interfaces to the classes used to create messages for the user and ask the user questions. These are explained here.

Messages and dialog boxes used to interact with users can be either modal or non-modal. A modal dialog is one that prevents the user from performing any other action (within the application) until the dialog has been dismissed. A non-modal dialog is one where the user can perform other functions before dealing with the dialog. Both are useful, and most widgets designed to interact with the user support both.

Contents

Message Procedures

There are three basic message procedures:

::tycho::inform {This message is created with the inform command}
::tycho::warn {This message is created with the warn command}
tkerror {This message is created with the tkerror command}
All three of these open modal dialogs. This, in fact, is the reason that when you click on the above, the dialog boxes appear one at a time, one after another, rather than all at once. The inform procedure posts a simple message, the warn procedure posts a message with an exclamation point bitmap, and the tkerror procedure posts a message with an error symbol bitmap.

You should not use the tkerror procedure directly, except in very rare circumstances. Instead, just call the Tcl command error when you wish to signal an error. See Error Handling.

There are also some non-modal mechanisms for posting messages. "Non-modal" means that execution continues as soon as the message is posted. Here is one simple way to provide information to the user:

::tycho::post {This message is created with the post command}
Note that with the post procedure you can leave the message on the screen as long as you like, and proceed with your work.

Asking the User Questions

You can ask the user questions, getting the response back and taking some action accordingly. The askuser procedure asks a yes-no question:

if [::tycho::askuser "Are you awake?"] {
    ::tycho::inform "You said yes!"
} {
    ::tycho::inform "Then how did you click on the No button?"
}
You can also prompt the user a typed response with the queryinfo procedure. For example:
::tycho::inform "You entered: [queryinfo {Enter a string}]"
The queryinfo procedure opens a dialog box with an entry box for the user to enter text. It returns the string that the user enters, or a null string if the user clicks on the Cancel button (or enters a null string). This procedure can take two optional arguments, a default string, and a width (in characters) for the entry box. For example,
::tycho::inform \
"You entered: [::tycho::queryinfo {Enter a string} {Default} 20]"


Copyright © 1996, The Regents of the University of California. All rights reserved.
Last updated: 96/04/09, comments to: eal@eecs.berkeley.edu